package cn.edu.neusoft.wuguangsheng.market.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.market.activity.UpDlCommentActivity;
import cn.edu.neusoft.wuguangsheng.market.bean.UserAllCommentBean;

/**
 * Created by little on 2018/4/22.
 */

public class CommentsAdapter extends BaseAdapter<UserAllCommentBean>{
    public CommentsAdapter(Context context, List<UserAllCommentBean> items, int layoutResource){
        super(context, items, layoutResource);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(context)
                .inflate(layoutResourse,parent,false);
        CommentsViewHolder commentsViewHolder=new CommentsViewHolder(itemView);
        return commentsViewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        CommentsViewHolder commentsViewHolder=(CommentsViewHolder) holder;
        UserAllCommentBean userAllCommentBean=items.get(position);
        final String name=userAllCommentBean.getFoodname();
        commentsViewHolder.cms_tv1.setText("菜名:"+name);
        final String content=userAllCommentBean.getContent();
        commentsViewHolder.cms_tv2.setText("评论内容:"+content);
        final  String time=userAllCommentBean.getCommenttime();

        commentsViewHolder.cms_tv3.setText("评论时间:"+time);
        final String orid=userAllCommentBean.getOrid();
        final String fid=userAllCommentBean.getFid();
        Picasso.with(context).load(items.get(position).getPic()).into(commentsViewHolder.cms_img);
        commentsViewHolder.cms_pl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, UpDlCommentActivity.class);
                intent.putExtra("fid",fid);
                intent.putExtra("orid",orid);
                intent.putExtra("content",content);
                context.startActivity(intent);
            }
        });
    }
}
